// import ElementUI from 'element-ui'
import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index/Index.vue'
import login from '../views/Login/login.vue'
Vue.use(VueRouter)

const routes = [
  { path: '/login', name: 'login', component: login },
  {
    path: '/', name: 'Index', component: Index,
    children: [
      { path: '/BasicInformation/Vehicle', name: 'Vehicle', component: () => import('../views/BasicInformation/Vehicle.vue') }, //车辆管理
      { path: '/BasicInformation/Owner', name: 'Owner', component: () => import('../views/BasicInformation/Owner.vue') }, //货主管理
      { path: '/BasicInformation/Outsource', name: 'Outsource', component: () => import('../views/BasicInformation/Outsource.vue') }, //外协单位管理
      { path: '/BasicInformation/OilCost', name: 'OilCost', component: () => import('../views/BasicInformation/OilCost.vue') }, //油费管理
      { path: '/BasicInformation/Circuit', name: 'Circuit', component: () => import('../views/BasicInformation/Circuit.vue') }, //线路管理

      { path: '/PersonnelRegister/rersonnelregister', name: 'rersonnelregister', component: () => import('../views/PersonnelRegister/rersonnelregister.vue') }, //员工登记
      { path: '/PersonnelRegister/LeaveDeal', name: 'LeaveDeal', component: () => import('../views/PersonnelRegister/LeaveDeal.vue') }, //离职办理
      { path: '/PersonnelRegister/PersonnelEntry', name: 'PersonnelEntry', component: () => import('../views/PersonnelRegister/PersonnelEntry.vue') }, //入职办理
      { path: '/PersonnelRegister/PositiveDeal', name: 'PositiveDeal', component: () => import('../views/PersonnelRegister/PositiveDeal.vue') },//转正办理
      { path: '/PersonnelRegister/Spectaculars', name: 'Spectaculars', component: () => import('../views/PersonnelRegister/Spectaculars.vue') },//人事看板

      { path: '/BaiduMap/Map', name: 'Map', component: () => import('../views/BaiduMap/Map.vue') }, //百度地图

      { path: '/Contract/ContractCarry', name: 'ContractCarry', component: () => import('../views/Contract/ContractCarry.vue') }, //承运合同
    ]
  },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  routes
})

// //拦截路由守卫
// router.beforeEach((to,form,next) => {
//   //to表示将要访问的路径
//   //from代表从哪个路径开跳转而来
//   //next表示一个函数 放行
//   if(to.path === '/') return next(); //如果访问的是登录页面就放行
//   const tokenStr=window.sessionStorage.getItem('token'); //获取存取的token
//   if(!tokenStr){
//     ElementUI.Message.error('您未登录,请赶快去登录，来看我们美好的页面吧！');
//     return next('/');
//   } //如果tokrn不存在就证明没有登录过 不允许强制跳转到登录页面
//   next(); //存在则放行
// })

export default router
